let marketModel = require("../models/market").marketList;

let marketDAO = function (){};

marketDAO.prototype = {
  //增
  save: function (json, callBack){
    let newMarket = new marketModel(json);
    newMarket.save(function (err){
      callBack(err);
    });
  },
  // //删
  remove: function (json, callBack){
    marketModel.remove(json, function (err){
      callBack(err);
    });
  },
  // //改
  update: function (json, condition, callBack){
    marketModel.update(json, condition, function (err){
      callBack(err);
    });
  },
  //查询列表
  findById: function (id, callBack){
    marketModel.find({userId: id}, function (err, doc){
      callBack(err, doc);
    });
  },
  //查询单个
  findOneById: function (id, callBack){
    marketModel.findOneById({_id: id}, function (err, doc){
      callBack(err, doc);
    });
  },
};

exports.marketMethod = new marketDAO();
